#ifndef __BSP_SPI_BUS_H__
#define __BSP_SPI_BUS_H__

#include "main.h"

void spi_bus_init(void);
uint8_t spi_TransmitReiceve_byte(uint8_t byte);
uint16_t spi_TransmitReiceve_halfword(uint16_t half_word);
void spi_lcd_gpio_Init(void);

uint8_t spi_Transmit_bytes(uint8_t* buffer, size_t buff_size);
uint8_t spi_read_write_byte(uint8_t TxData);


#define SCLK        11	//PB13--->>TFT --SCL/SCK
#define MISO        12	
#define MOSI        13	//PB15 MOSI--->>TFT --SDA/DIN

#define SPI_MOSI  PGout(MOSI)
#define SPI_SCLK  PGout(SCLK)
#define SPI_MISO  PGin(MISO)

//#define LCD_CS_SET(x) LCD_CTRL->ODR=(LCD_CTRL->ODR&~LCD_CS)|(x ? LCD_CS:0)


#define	SPI_MOSI_SET  	SPI_MOSI=1 //LCD_CTRL->BSRR=SPI_MOSI    
#define	SPI_SCLK_SET  	SPI_SCLK=1 //LCD_CTRL->BSRR=SPI_SCLK    


//液晶控制口置0操作语句宏定义

#define	SPI_MOSI_CLR  	SPI_MOSI=0 //LCD_CTRL->BRR=SPI_MOSI    
#define	SPI_SCLK_CLR  	SPI_SCLK=0 //LCD_CTRL->BRR=SPI_SCLK    


void spi_soft_gpio_config(void);
void  SPI_soft_WriteData(u8 Data);
uint8_t spi_soft_Transmit_bytes(uint8_t* buffer, size_t buff_size);
#endif 